#!/usr/bin/env node

import { isPathInIgnoredDirectory } from './dist/utils/path-utils.js';
import { simpleCodeParser } from './dist/processors/simple-parser.js';
import { globSync } from 'glob';
import { SUPPORTED_EXTENSIONS } from './dist/constants/index.js';
import path from 'path';

// Test with the exact same logic as the directory scanner
const directoryPath = process.cwd();
console.log('Directory path:', directoryPath);

const pattern = `**/*{${SUPPORTED_EXTENSIONS.join(',')}}`;
console.log('Pattern:', pattern);

const files = globSync(pattern, {
  cwd: directoryPath,
  absolute: true,
  ignore: [
    '**/node_modules/**',
    '**/.git/**',
    '**/dist/**',
    '**/build/**',
    '**/coverage/**',
    '**/.next/**',
    '**/.nuxt/**',
    '**/target/**',
    '**/.*/**',        // Exclude all hidden directories
    '**/.*',           // Exclude all hidden files
  ],
});

console.log(`Found ${files.length} files`);

// Test the first few files with absolute paths
for (let i = 0; i < Math.min(5, files.length); i++) {
    const filePath = files[i];
    console.log(`\n=== Testing ${filePath} ===`);
    
    // Check if in ignored directory
    const isIgnored = isPathInIgnoredDirectory(filePath);
    console.log(`Ignored directory check: ${isIgnored}`);
    
    if (isIgnored) {
        console.log('❌ This file would be skipped due to ignored directory');
    } else {
        console.log('✅ This file should not be skipped');
    }
}